package com.zf.wms.business.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zf.wms.business.entity.Bulletin;
import com.zf.wms.business.service.BulletinService;
import com.zf.wms.business.utils.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Author: Mine
 * @CreateDate: 2019/10/9
 * @email: 1943511692@qq.com
 * @Version: 1.0.0
 */

@RestController
@RequestMapping(value = "/bulletin")
public class BulletinController {

    @Autowired
    private BulletinService bulletinService;

    @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public ResultMap getList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                          @RequestParam(value = "pageSize", defaultValue = "1") Integer pageSize) {

        PageHelper.startPage(pageNum, pageSize);
        List<Bulletin> bulletin = bulletinService.list();
        PageInfo<Bulletin> pageInfo = new PageInfo<>(bulletin);
        return ResultMap.ok().put("bulletin", pageInfo.getList());
    }
}
